home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1417 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.4 KB

  1. Path: atglab.bls.com!Alun.Champion
  2. From: Alun.Champion@bridge.bst.bls.com (Alun Champion)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Deep/Shallow Copying?
  5. Date: 10 Jan 1996 22:09:19 GMT
  6. Organization: Computer People Inc.
  7. Message-ID: <ALUN.CHAMPION.96Jan10170919@g7240065.bridge.bst.bls.com>
  8. References: <4d1bhe$1lto@bocanews.bocaraton.ibm.com>
  9. NNTP-Posting-Host: bstfirewall.bst.bls.com
  10. In-reply-to: pani@genius.tisl.soft.net's message of 10 Jan 1996 21:36:46 GMT
  11.  
  12. In article <4d1bhe$1lto@bocanews.bocaraton.ibm.com> pani@genius.tisl.soft.net writes:
  13.  
  14. :   What is Deep copying or Shallow copying? Is this something
  15. :  to do with a Copy constructor?
  16.  
  17. Yes.
  18. A picture may illustrate the scenario  
  19.  
  20. Imagine object 'a' contains a pointer or reference to object 'b' then:
  21.  
  22.    Original              Shallow Copy           Deep Copy
  23.  
  24.    ---------           ---------           ---------
  25.    |   a   |           | new a |           | new a |
  26.    ---------           ---------           ---------
  27.        |               |               |
  28.        V               V               V
  29.    ---------           ---------           ---------
  30.    |   b   |           |   b   |           | new b |
  31.    ---------           ---------           ---------
  32.  
  33. Of course 'a' may contain many pointers and/or references which in turn
  34. may contain many pointers and/or references etc... Obviously the deeper
  35. the structure the more expensive deep copy is compared to shallow copy.
  36.  
  37. Hope this helps
  38. Regards
  39.  
  40.    -A.
  41.  
  42.  
  43.  
  44. -- 
  45. | A.Champion                |
  46.